From af785dee41395dbf3b76ce47f7e9339976c10d55 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 27 Sep 2011 17:32:16 +0100 Subject: [PATCH] xl: fixup "xl save" command line handling. The save file paramter is required so ensure we have enough arguments. The config filename is optional so do not use argv[optind+3], which may well happen to be NULL when the paramter is not present but relying on that is pretty gross. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Committed-by: Ian Jackson --- tools/libxl/xl_cmdimpl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 10a38c8520..fb6497bf57 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2856,8 +2856,8 @@ int main_migrate_receive(int argc, char **argv) int main_save(int argc, char **argv) { - const char *filename = NULL, *p = NULL; - const char *config_filename; + const char *filename, *p; + const char *config_filename = NULL; int checkpoint = 0; int opt; @@ -2871,14 +2871,16 @@ int main_save(int argc, char **argv) } } - if (argc-optind > 3) { + if (argc-optind < 2 || argc-optind > 3) { help("save"); return 2; } p = argv[optind]; filename = argv[optind + 1]; - config_filename = argv[optind + 2]; + if ( argc - optind >= 3 ) + config_filename = argv[optind + 2]; + save_domain(p, filename, checkpoint, config_filename); return 0; } -- 2.30.2